package com.api.gbhg.lbj.action;

import com.api.gbhg.lbj.dao.GeneralProjectDao;
import com.api.gbhg.liwenjun.VersionFlowUtil;
import com.api.gbhg.zengping.dao.PropertyManagementCostDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.conn.RecordSet;
import weaver.general.TimeUtil;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lbj
 * @version 1.0
 * @description: TODO 警察在职行政人员工资津贴-经费额度入库
 * @date 2021/1/5 13:19
 */
public class PoliceFundStorage implements Action {
    private static final Logger logger = LoggerFactory.getLogger("gbhg");
    @Override
    public String execute(RequestInfo requestInfo) {
        logger.info("测试进入警察在职行政人员工资津贴经费额度入库Action方法");
        GeneralProjectDao dao=new GeneralProjectDao();
        PropertyManagementCostDao p=new PropertyManagementCostDao();
        String requestid = requestInfo.getRequestid();
        RecordSet rs = dao.getFundstorageById(requestid,"uf_jczzxzrygzjtbjfbb","uf_jczzxzrygzjtbjfbb_dt2");
        Map<String,String> map=new HashMap<>();
        RecordSet recordSet = dao.deleteWorkflowByid(requestid);
        recordSet.next();
        boolean flag=false;
        while (rs.next()){
            map.put("requestId",rs.getStringNoTrim("lcjlsqjlid"));
            map.put("lcbj",rs.getStringNoTrim("lcbj"));
            map.put("lcjlid",rs.getStringNoTrim("lcjlsqjlid"));
            map.put("nd",rs.getStringNoTrim("ysnd"));
            map.put("ze",rs.getStringNoTrim("hjwy"));
            map.put("bmzcjjfl",rs.getStringNoTrim("bmyszcjjfl"));
            map.put("zfjjfl",rs.getStringNoTrim("dyzfjjfl"));
            //map.put("gkdw",rs.getStringNoTrim("gkdw"));
            map.put("sydw",rs.getStringNoTrim("sydw"));
            String syed = "0.00";
            if (rs.getStringNoTrim("hjwy").equals("")) {
                map.put("ze","0.00");
                syed = "0.00";
            }else {
                syed=rs.getStringNoTrim("hjwy");
            }
            map.put("syed",syed);
            map.put("dj","0.00");
            map.put("sbdw",rs.getStringNoTrim("sbdw"));
            map.put("xmmc",rs.getStringNoTrim("xmmin"));
            map.put("modedatamodifier",rs.getStringNoTrim("jbr"));
            map.put("modedatamodifydatetime", TimeUtil.getCurrentTimeString());//当前日期时间
            logger.info("警察在职行政人员map"+map.toString());
            flag = p.insertBudgeLines(map);
        }
        if(!flag){
            logger.info("============================经费额度同步失败,数据同步异常======================================");
            requestInfo.getRequestManager().setMessagecontent("同步经费额度数据异常");
            requestInfo.getRequestManager().setMessageid("1");
            return FAILURE_AND_CONTINUE;
        } else {
        return Action.SUCCESS;
     }
    }
}
